Skip to main content

Basic authentication

Basic authentication is supported for legacy reasons.

1. Overview

Basic - or HTTP - Authentication simply means the client sends a username and password with every request. It is very simple to set up, but the credentials are encoded in plain text (but naturally protected by TLS). Basic authentication is an outdated industry standard and any new Jakamo API connectors should not use it.
In the not-too-distant future Jakamo will retire Basic authentication.

2. Steps to use Basic authentication

  1. Log in to Jakamo as a user with Company Admin credentials
  2. From the upper left menu, select Integrations
  3. From the listing of your integrations, select Change Credentials
  4. Enter a username and password. The username must be at least 5 characters long, and passwords are checked to make sure they are not extremely easy to guess, and that they are not found in lists of leaked passwords found on the dark web.

3. Testing using Postman

  1. Open Postman and create a new request
  2. In the Authorization tab, for Type, select Basic
  3. Enter the username and password you selected
  4. Run the request

3. C# sample

using System.Net.Http.Headers;
using System.Text;

const string username = "username";
const string password = "password";

var encodedCredentials = Convert.ToBase64String(
Encoding.UTF8.GetBytes($"{username}:{password}")
);
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
encodedCredentials
);
var request = await httpClient.GetAsync("{url}/order/response");
var responseContent = await request.Content.ReadAsStringAsync();
Console.WriteLine(responseContent);
C:/Projects/Labs/JakamoBasicAuthSample/JakamoBasicAuthSample/bin/Debug/net7.0/JakamoBasicAuthSample.exe 
<status>No more messages available.</status>

4. Java sample

package com.example;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.net.http.HttpRequest;
import java.util.Base64;

public final class App {
public static void main(String[] args) {

try {

String encoding = Base64.getEncoder().encodeToString(("username:password").getBytes());

HttpClient client = HttpClient.newHttpClient();

HttpRequest request = HttpRequest.newBuilder()
.GET()
.uri(new URI("{url}/order/response"))
.header("Authorization", "Basic " + encoding)
.build();


HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
$ java com.example.App
<status>No more messages available.</status>

5. Node.JS sample

const axios = require('axios');
const res = axios.get('{url}/order/response', {
auth: {
username: 'username',
password: 'password'
}
}).then(response => {
console.log(response.data);
});
C:\Program Files\nodejs\node.exe .\app.js
<status>No more messages available.</status>
Help & Support

Didn't you find what you were looking for? Send an email to Jakamo support (support@thejakamo.com) and we will help you.